import search from "./search/search.js";
import approved from "./approved/approved.vue";
import toBeSubmitted from "./toBeSubmitted/toBeSubmitted.vue";
import toBereviewed from "./toBereviewed/toBereviewed.vue";
import rejected from "./rejected/rejected.vue";

const tabName = [
    "审核通过",
    "待提交",
    "待审核",
    "已驳回",
]
export default {
    mixins: [search],
    components: {
        approved,
        toBeSubmitted,
        toBereviewed,
        rejected
    },
    data() {
        return {
            keyName: "1",
            tab: {
                approved: "审核通过",
                toBeSubmitted: "待提交",
                toBereviewed: "待审核",
                rejected: "已驳回",
            },
        }
    },
    mounted() {
        this.getList()
    },
    methods: {
        callback(key) {
            this.keyName = key
            switch (key) {
                case '1':
                    this.$refs.approved.getList() //审核通过列表
                    break;
                case '2':
                    this.$refs.toBeSubmitted.getList() //待提交列表
                    break;
                case '3':
                    this.$refs.toBereviewed.getList() //待审核列表
                    break;
                case '4':
                    this.$refs.rejected.getList() //已驳回列表
                    break;
                default:
                    break;
            }
            this.trigger()
        },
        getList() {
            this.$refs.approved.getList()       //审核通过列表
            this.$refs.toBeSubmitted.getList()  //待提交列表
            this.$refs.toBereviewed.getList() //待审核列表
            this.$refs.rejected.getList() //已驳回列表
        },
        trigger() {
            this.tab.approved = `${tabName[0]}(${this.$refs.approved.pagination.total})`
            this.tab.toBeSubmitted = `${tabName[1]}(${this.$refs.toBeSubmitted.pagination.total})`
            this.tab.toBereviewed = `${tabName[2]}(${this.$refs.toBereviewed.pagination.total})`
            this.tab.rejected = `${tabName[3]}(${this.$refs.rejected.pagination.total})`
        },
        addShangpin() {
            if (this.keyName == "1") {
                this.$refs.approved.getList()       //审核通过列表
            } else if (this.keyName == "2") {
                this.$refs.toBeSubmitted.getList()  //待提交列表
            } else if (this.keyName == "3") {
                this.$refs.toBereviewed.getList() //待审核列表
            } else if (this.keyName == "4") {
                this.$refs.rejected.getList() //已驳回列表
            }
        },
        drShangpin() {
            if (this.keyName == "1") {
                this.$refs.approved.getList()       //审核通过列表
            } else if (this.keyName == "2") {
                this.$refs.toBeSubmitted.getList()  //待提交列表
            } else if (this.keyName == "3") {
                this.$refs.toBereviewed.getList() //待审核列表
            } else if (this.keyName == "4") {
                this.$refs.rejected.getList() //已驳回列表
            }
        }
    }
}